<template>
  <el-row class="panel-group">
    <el-col :xs="12" :sm="12" :lg="{ span: '4-8' }"
            class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-text">流程总数</div>
        <div class="card-panel-icon-wrapper icon-people" style="padding: 0">
          <svg-icon icon-class="businessUsers" class-name="card-panel-icon" />
          <CountTo
            :start-val="0"
            :end-val="countData.processCount"
            :duration="2600"
            class="card-panel-num"
          />个
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="{ span: '4-8' }"
            class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-text">流程实例总数</div>
        <div class="card-panel-icon-wrapper icon-people" style="padding: 0">
          <svg-icon icon-class="userAdd" class-name="card-panel-icon" />
          <CountTo
            :start-val="0"
            :end-val="countData.processInstanceCount"
            :duration="2600"
            class="card-panel-num"
          />个
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="{ span: '4-8' }"
            class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-text">今日新增流程</div>
        <div class="card-panel-icon-wrapper icon-people" style="padding: 0">
          <svg-icon icon-class="orgCount" class-name="card-panel-icon" />
          <CountTo
            :start-val="0"
            :end-val="countData.processTodayCreatedCount"
            :duration="2600"
            class="card-panel-num"
          />个
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
import processDetailApi from '@/framework/api/workflow/processOverview/index'

export default {
  components: {
    CountTo
  },
  data() {
    return {
      countData: {
        processCount: 0,
        processInstanceCount: 0,
        processTodayCreatedCount: 0
      }
    }
  },
  created() {
    this.getCountByUser()
  },
  methods: {
    async getCountByUser() {
      const res = await processDetailApi.dataStatistics()
      this.countData = res.data
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  padding: 40px 0px;
  .card-panel-col {
    padding: 0 !important;
  }

  .card-panel {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    line-height: 20px;
    margin-left: 95px;
    border-right: 1px solid #f2f3f5;
    .card-panel-text {
      font-size: 12px;
      color: #131414;
      white-space: nowrap;
      line-height: 20px;
    }
    .card-panel-icon-wrapper {
      padding-left: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
      display: flex;
      margin-top: 8px;
      align-items: center;
      .el-image {
        width: 42px;
        height: 42px;
      }
       .card-panel-num {
        line-height: 24px;
        margin-left: 8px;
        font-size: 26px;
        font-weight: bold;
        color: #1d2129;
      }
    }
    .card-panel-icon {
      font-size: 32px;
    }
  }
}
.el-col-lg-4-8 {
  width: 20%;
}
@media (max-width: 1024px) {
  .panel-group .card-panel {
    display: block;
    height: 120px;
  }
  .panel-group .card-panel .card-panel-icon-wrapper {
    width: 30%;
  }
  .card-panel-description {
    margin: 0 !important;
  }
  .panel-group .card-panel-col {
    width: 33% !important;
    text-align: center;
  }
  .panel-group .card-panel .card-panel-icon-wrapper {
    width: 100% !important;
  }
  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    // height: 100%;
    margin: 0 !important;
    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
